//
//  YTOneLevelCell.m
//  YUNT
//
//  Created by 梁炜东 on 2017/11/12.
//  Copyright © 2017年 梁炜东. All rights reserved.
//

#import "YTOneLevelCell.h"
#import "XYButton.h"

@interface YTOneLevelCell()
@property(nonatomic, strong)XYButton *btn;
@end

@implementation YTOneLevelCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.userInteractionEnabled = YES;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self addSubview:self.btn];
        [_btn mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.leading.trailing.equalTo(self);
        }];
    }
    return self;
}
-(XYButton *)btn
{
    if (!_btn)
    {
        _btn = [XYButton buttonWithType:UIButtonTypeCustom];
        _btn.titlePosition = XYButtonTitlePositionBottom;
        _btn.userInteractionEnabled = NO;
        _btn.backgroundColor = [UIColor clearColor];
        [_btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_btn setTitleColor:YTColorAlpha(92, 205, 225, 1) forState:UIControlStateSelected];
    }
    return _btn;
}
-(void)configData:(NSArray *)arr
{
    [_btn setTitle:arr[2] forState:UIControlStateNormal];
    if (publicModel.isPhoto)
    {
        if (publicModel.photoModel == _indexPath.row)
        {
            [_btn setImage:IMAGE(arr[1]) forState:UIControlStateNormal];
            _btn.selected = YES;
        }else
        {
            [_btn setImage:IMAGE(arr[0]) forState:UIControlStateNormal];
            _btn.selected = NO;
        }
    }else
    {
        if (publicModel.videoModel == _indexPath.row)
        {
            [_btn setImage:IMAGE(arr[1]) forState:UIControlStateNormal];
            _btn.selected = YES;
        }else
        {
            [_btn setImage:IMAGE(arr[0]) forState:UIControlStateNormal];
            _btn.selected = NO;
        }
    }
}
@end
